<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/conf/config.php';

if (!$_POST['SEQNO']) {
	echo json_endoce('error');
	exit();
}

$SEQ = explode(",", $_POST['SEQNO']);

$dbconn = @mysql_connect($dbhost, $dbuser, $dbpass);
@mysql_select_db($dbname, $dbconn);

foreach ($SEQ as $SEQNO) {
	$sel_query = "select CPIC, PNG from qr_data where SEQNO = '" . $SEQNO . "'";
	$del_query = "delete from qr_data where SEQNO = '" . $SEQNO . "'";
	
	$result = @mysql_fetch_array(@mysql_query($sel_query, $dbconn));
	
	if ($result['CPIC'] != "" && is_file($_SERVER['DOCUMENT_ROOT'].'/'.$code_loc.$result['CPIC']))
		@unlink($_SERVER['DOCUMENT_ROOT'].'/'.$code_loc.$result['CPIC']);
	
	if ($result['PNG'] != "" && is_file($_SERVER['DOCUMENT_ROOT'].'/'.$code_loc.$result['PNG']))
		@unlink($_SERVER['DOCUMENT_ROOT'].'/'.$code_loc.$result['PNG']);
	
	@mysql_query($del_query, $dbconn);
}

@mysql_close($dbconn);

echo json_encode('success');
?>